

#include "UFLBaseType.h"
#include "UFLToolKit.h"

using namespace ufl;

vector<string> toolkit::split(ufl_string src, const string& sep)
{
	ufl_uint32 start = 0;
    ufl_string::size_type end = src.find_first_of(sep);

	vector<ufl_string> output;

	while (end != ufl_string::npos)
	{
		ufl_string sub = src.substr(start, end - start);
		src.erase(start, end - start + 1);
		end = src.find_first_of(sep);
		output.push_back(sub);
	}

	output.push_back(src.substr(start, src.size()));

	return output;
}

ufl_void toolkit::dumpGLInfo()
{
	const ufl_ubyte *renderer = glGetString(GL_RENDERER);
	const ufl_ubyte *vendor = glGetString(GL_VENDOR);
	const ufl_ubyte *version = glGetString(GL_VERSION);
	const ufl_ubyte *glslVersion = glGetString(GL_SHADING_LANGUAGE_VERSION);

	ufl_int32 major, minor;
	glGetIntegerv(GL_MAJOR_VERSION, &major);
	glGetIntegerv(GL_MINOR_VERSION, &minor);

	printf("-------------------------------------------------------------\n");
	printf("GL Vendor    : %s\n", vendor);
	printf("GL Renderer  : %s\n", renderer);
	printf("GL Version   : %s\n", version);
	printf("GL Version   : %d.%d\n", major, minor);
	printf("GLSL Version : %s\n", glslVersion);
	printf("-------------------------------------------------------------\n");

// 	ufl_int32 nExtensions;
// 	glGetIntegerv(GL_NUM_EXTENSIONS, &nExtensions);
// 	for (int i = 0; i < nExtensions; i++) {
// 		printf("%s\n", glGetStringi(GL_EXTENSIONS, i));
// 	}
}